/*
 * Copyright (c) 2023 iQi.Co.Ltd. All rights reserved.
 */
 
using IQIGame.Onigao.Framework;
using System.Collections.Generic;
using System.Linq;
using System;
using NetProtocol.Enum;

namespace NetProtocol.POD {

	/// <summary>
	/// 
	/// module : battleLogic
	/// </summary>
	public class BattleUpdatePOD : IPOD 
    {
        public readonly static Func<BattleUpdatePOD> FACTORY = () => new BattleUpdatePOD();
		public static Func<BattleUpdatePOD> DynamicFactory = FACTORY;
        
		/*-- members --*/
		/// <summary>
        /// 
        /// </summary>
		public int executerId;
		/// <summary>
        /// 
        /// </summary>
		public int type;
		/// <summary>
        /// 
        /// </summary>
        public object data;
        public static Action<object, SOutputStream> Serial_data;
        public static Func<SInputStream, object> UnSerial_data;
		
		
		
		/*-- constructors --*/
		public BattleUpdatePOD() {}
		public BattleUpdatePOD(int executerId, int type, object data) {
			this.executerId = executerId;
			this.type = type;
			this.data = data;
		}
	      public void Serial(SOutputStream _out) {
            _out.Write_int(executerId);
            _out.Write_int(type);
            Serial_data.Invoke(data, _out);
        }
        
        public void UnSerial(SInputStream _in) {
            if(!_in.HasRemaining()) return;
            executerId = _in.Read_int();
            if(!_in.HasRemaining()) return;
            type = _in.Read_int();
            if(!_in.HasRemaining()) return;
            data = UnSerial_data.Invoke(_in);
        }
		
		public BattleUpdatePOD Clone() {
            BattleUpdatePOD o = DynamicFactory();
            o.executerId = executerId;
            o.type = type;
            o.data = data;
            return o;
        }
        
        public void Clear() {
            executerId = default;
            type = default;
            data = default;
        }
		
        public override string ToString() {
			string str = "";
			str += "BattleUpdatePOD [";
			str += "executerId=";
			str += executerId;
			str += ", type=";
			str += type;
			str += ", data=";
			str += data;
			str += "]";
			return str;
		}
		
	}
}